using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Informatika.Common;

namespace FinanceStats.Common
{
    public static class AppSettingsHelper
    {

        public static string GetWebConfigValue(string key)
        {
            string retVal = String.Empty;

            try
            {
                retVal = @ConfigurationManager.AppSettings[key].ToString();
            }
            catch (Exception exc)
            {
                LogManager.LogExceptionThrow(exc);
            }

            if (retVal.Length < 1)
            {
                LogManager.LogExceptionThrow(new ConfigurationErrorsException(key + " is not set in web.config!"));
            }
            return retVal;
        }

        public static bool WebConfigValueExists(string key)
        {
            bool res = false;
            res = ConfigurationManager.AppSettings[key] != null;
            return res;
        }
    }
}
